package resource

import (
	"aifuture.cloud/hanlders"
	"aifuture.cloud/services/resource"
	"github.com/gin-gonic/gin"
)

type ResourceHandler struct {
}

func NewResourceHandler() *ResourceHandler {
	return &ResourceHandler{}
}

func (t *ResourceHandler) List(c *gin.Context) {
	resProxy := resource.NewResourceSvc(resource.NewResourceProxy())
	err, tpList := resProxy.List()
	hanlders.HandlerError(err, c)
	hanlders.SuccessResponseHandler(c, tpList)
}
type ResourceDetailReq struct {
	ResourceId int `query:"res_id" binding:"required"`
}
func (t *ResourceHandler) Detail(c *gin.Context) {
	var ResourceDetailReq ResourceDetailReq
	err := c.ShouldBind(&ResourceDetailReq)
	hanlders.HandlerError(err, c)
	resProxy := resource.NewResourceSvc(resource.NewResourceProxy())
	err, tpList := resProxy.Detail(ResourceDetailReq.ResourceId)
	hanlders.HandlerError(err, c)
	hanlders.SuccessResponseHandler(c, tpList)
}
